#ifndef CLOCK_STOPWATCH_HPP
#define CLOCK_STOPWATCH_HPP

#include <cpp3ds/Graphics/Drawable.hpp>
#include <cpp3ds/Graphics/Text.hpp>
#include <cpp3ds/Window/Event.hpp>
#include <cpp3ds/System/Clock.hpp>
#include "TweenObjects.hpp"
#include "Chronometer.hpp"
#include "LapList.hpp"
#include "GUI/ScrollBar.hpp"
#include <TweenEngine/Tween.h>
#include <TweenEngine/TweenManager.h>
#ifndef EMULATION
#include <3ds.h>
#endif

namespace Clock {

class Stopwatch : public cpp3ds::Drawable, public util3ds::TweenTransformable<cpp3ds::Transformable> {
public:
	void update(float delta);
	void processEvent(const cpp3ds::Event& event);

	Stopwatch();
	~Stopwatch();

	void play();
	void pause();
	void stop();
	void toggle();
	void reset();
	bool isRunning();
	cpp3ds::Time getElapsedTime();

protected:
	virtual void draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) const;

private:
	util3ds::TweenText m_textStopwatch;
	util3ds::TweenText m_textStopwatchMilliseconds;

	util3ds::TweenCircleShape m_startButton;
	util3ds::TweenText m_textStart;
	bool m_stopButtonInteract;
	util3ds::TweenCircleShape m_stopButton;
	util3ds::TweenText m_textStop;

	util3ds::TweenText m_textAddLap;
	util3ds::TweenText m_textClearList;

	LapList m_lapList;
	ScrollBar m_scrollbarLapList;

	sftools::Chronometer m_mainStopwatch;

	TweenEngine::TweenManager m_tweenManager;

};

} // namespace Clock

#endif // CLOCK_STOPWATCH_HPP
